package com.example.shardingdemo;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
import com.example.shardingdemo.entity.User;
import com.example.shardingdemo.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;


@MapperScan(basePackages = "com.example.shardingdemo.dao")
@SpringBootApplication//(exclude = {DataSourceAutoConfiguration.class})
public class ShardingDemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(ShardingDemoApplication.class, args);
        UserService bean = run.getBean(UserService.class);
        for (int i = 0; i < 20; i++) {
            User user = new User();
            user.setAge(i);
            user.setId(i);
            user.setName("test" + i);
        bean.save(user);
        }
    }

}
